package com.ae.shield.client.gui.util;

import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.client.Minecraft;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.StringTextComponent;
import net.minecraftforge.fml.client.gui.GuiUtils;
import net.minecraftforge.fml.client.gui.widget.ExtendedButton;

public class ButtonCustomized extends ExtendedButton {
    private final ResourceLocation location;
    private final int uOff;
    private final int vOff;

    public ButtonCustomized(int xPos, int yPos, int width, int height, int uOff, int vOff, ResourceLocation location, IPressable handler) {
        super(xPos, yPos, width, height, new StringTextComponent(""), handler);
        this.location = location;
        this.uOff = uOff;
        this.vOff = vOff;
    }

    @Override
    public void renderButton(MatrixStack mStack, int mouseX, int mouseY, float partial) {
        if (this.visible)
        {
            Minecraft mc = Minecraft.getInstance();
            this.isHovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
            int k = this.getYImage(this.isHovered());
            GuiUtils.drawContinuousTexturedBox(mStack, location, this.x, this.y, uOff, vOff + (k - 1) * height, this.width, this.height, 15, 10, 2, 3, 2, 2, this.getBlitOffset());
            this.renderBg(mStack, mc, mouseX, mouseY);
        }
    }
}
